﻿/**
 *	This is called when the Options dialog is opened 
 *	and simply places any existing value for postcode in the edit box.
 */
function onOpen() {
	editPostCode.value = options.getValue('postcode');

	if(options.getValue('checkInterval') == undefined || options.getValue('checkInterval') <= 0){
		editCheckInterval.value = "30";
	}else{
		editCheckInterval.value = options.getValue('checkInterval');
	}

	if(options.getValue('showPhoto') == true){
		radioYesPhoto.value = true;
		radioNoPhoto.value = false;
	}else{
		radioYesPhoto.value = false;
		radioNoPhoto.value = true;
	}
}

function onCancel() {
  // No settings will be saved.
}

/**
 *	Saves the options when the user clicks the okay button.
 */
function onOk() {
	debug.trace(editCheckInterval.value);
	debug.trace(radioYesPhoto.value);

	options.putValue('postcode', editPostCode.value);
	options.putValue('checkInterval', editCheckInterval.value);

	if(radioYesPhoto.value == true){
		options.putValue('showPhoto', true);
	}else{
		options.putValue('showPhoto', false);
	}
}
